package io;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

/**
 * 自行完成流连接创建PrintWriter
 *
 * 简易记事本工具
 *
 */
public class PWDemo2 {
    public static void main(String[] args) throws FileNotFoundException {
        //创建字符流时可以使用追加模式
        FileOutputStream fos = new FileOutputStream("note.txt",true);
        //创建转换流时可以指定字符集
        OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
        BufferedWriter bw = new BufferedWriter(osw);
        PrintWriter pw = new PrintWriter(bw);

        Scanner scan = new Scanner(System.in);
        String str;
        while (!"exit".equals(str=scan.nextLine())){
            pw.println(str);
        }

        pw.close();

    }
}
